package model.backup.handlers;

import database.Database;
import java.sql.SQLException;
import model.backup.BackupCustomer;

/**
 * Denne klasse bruges til at hente al data i bs_customer og returnere det
 * @author junjie
 */
public abstract class BackupCustomerHandler {
    
    /**
     * Henter alle rækker i bs_customer og returnerer et BackupCustomer[] model 
     * @return BackupCustomer[]
     * @throws ClassNotFoundException
     * @throws SQLException 
     */
     public static BackupCustomer[] getCustomer() throws ClassNotFoundException, SQLException
    {
        BackupCustomer[] customerArray = null;
        
        Database db = new Database();
        
        String[][] result = db.getFromDB("bs_customer", "", "", "", 
                                            "id", "name", "mortician");
        customerArray = new BackupCustomer[result.length];
        
        db.closeDB();
        
        for(int i = 0; i<result.length; i++){
            customerArray[i] = new BackupCustomer(Integer.parseInt(result[i][0]),result[i][1],Integer.parseInt(result[i][2]));
        }
        return customerArray;
    }
}